<?php
class Vo {
	public $data = null;
	
	public function __construct($data = null) {
		$this->data = $data;
	}
	
	public function set($key, $val = null) {
		$this->data[$key] = $val;
	}
	
	public function get($key, $default = null) {
		if ($this->data) {
			return isset($this->data[$key]) ? $this->data[$key] : $default;
		}
		return isset($_REQUEST[$key]) ? $_REQUEST[$key] : $default;
	}
	
	public function getL($name, $languageId, $key, $default = null) {
		if ($this->data) {
			return isset($this->data[$name][$languageId][$key]) ? $this->data[$name][$languageId][$key] : $default;
		}
		return isset($_REQUEST[$name][$languageId][$key]) ? $_REQUEST[$name][$languageId][$key] : $default;
	}
	
	/**
	 * read from post data or configuration
	 * @param string $key
	 * @param mix $default
	 */
	public function getC($key, $default = null) {
		$val = isset($_POST[$key]) ? P($key) : C($key);
		return ($val === null) ? $default : $val;
	}
}